A good answer might be:

It activates Triangle() with a parameter of 1.


Base Case

Finally we are at the base case. When Triangle() is activated with a parameter of 1, the if statement causes the value 1 to be immediately returned.

The chain of activations is called an activation chain. The picture on this page shows the activation chain when it has reached the base case.

int Triangle( int N )
{
  if ( N == 1 )
    return 1;
  else
    return N + Triangle( N-1 );
}

Now look again at the activation where N = 2. It has just gotten a value back from Triangle(1):


                  2
                  |
int Triangle( int N )
{
  if ( N == 1 )
    return 1;
  else
    return N + Triangle( N-1 );
           |   ------+-------
           |         |
           2         1
}

 

QUESTION 14:

What value does this activation return to its caller?